﻿using System;
using System.Data;

namespace mooSQL.data
{

    /// <summary>
    /// A type handler for data-types that are supported by the underlying provider, but which need
    /// a well-known UdtTypeName to be specified
    /// </summary>
    public class UdtTypeHandler : ITypeHandler
    {
        private readonly string udtTypeName;
        /// <summary>
        /// Creates a new instance of UdtTypeHandler with the specified <see cref="UdtTypeHandler"/>.
        /// </summary>
        /// <param name="udtTypeName">The user defined type name.</param>
        public UdtTypeHandler(string udtTypeName)
        {
            if (string.IsNullOrEmpty(udtTypeName)) throw new ArgumentException("Cannot be null or empty", udtTypeName);
            this.udtTypeName = udtTypeName;
        }

        object ITypeHandler.Parse(Type destinationType, object value)
        {
            return value is DBNull ? null : value;
        }


    }
    
}
